package com.jhgsys.internal.system.controller;

import cn.hutool.core.date.DateUtil;
import com.jhgsys.internal.common.controller.BaseController;
import com.jhgsys.internal.common.entity.FebsConstant;
import com.jhgsys.internal.common.entity.FebsResponse;
import com.jhgsys.internal.common.exception.FebsException;
import com.jhgsys.internal.common.utils.FebsUtil;
import com.jhgsys.internal.system.dto.GanttChartDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

/**
 * 甘特图 Controller
 *
 * @author 冯海军
 * @date 2023-03-05
 */
@Slf4j
@Validated
@Controller
public class GanttChartController extends BaseController {

    @GetMapping(FebsConstant.VIEW_PREFIX + "gantt/ganttProject")
    @RequiresPermissions("ganttProject:view")
    public String ganttProject(Model model) {
        model.addAttribute("toUserName", null);
        model.addAttribute("toUserId", null);
        model.addAttribute("contractList", null);
        model.addAttribute("userList", null);
        return FebsUtil.view("system/gantt/ganttProject");
    }


    /**
     * 甘特图测试数据
     */
    @ResponseBody
    @GetMapping("/gantt/projectPlan")
    public FebsResponse projectPlan() throws FebsException {
        try {
            List<GanttChartDto> GanttChartDtoList = new ArrayList<>();
            GanttChartDto ganttChartDto = new GanttChartDto();
            ganttChartDto.setId("1760245447000436737");
            return new FebsResponse().success();
        } catch (Exception e) {
            String message = "甘特图测试数据";
            log.error(message, e);
            throw new FebsException(message);
        }
    }

}
